using System.Linq;
using NUnit.Framework;

namespace Solver
{
	/// <summary>
	/// Calculate the sum of all the primes below two million.
	/// </summary>
	public class Problem010 : SelfChecker, IProblem
	{
		public int Id
		{
			get { return 10; }
		}

		public string Solve()
		{
			return Solve(2000000).ToString();
		}

		[Test]
		public override void Check()
		{
			Assert.AreEqual(17, Solve(10));
			Assert.AreEqual(142913828922, Solve(2000000));
		}

		private static long Solve(int param)
		{
			return new PrimeNumbersSource("primes-10m.txt").LongPrimes().TakeWhile(p => p <= param).Sum();
		}
	}
}